package com.leave.mos.service.impl;

import com.leave.base.MD5Util;
import com.leave.mos.dao.UserDao;
import com.leave.mos.entity.User;
import com.leave.mos.service.LoginService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @ClassName LoginServiceImpl
 * @Description TODO
 * @Author lh
 * @Date 2021/7/1 17:32
 * @Version 1.0
 **/
@Service
public class LoginServiceImpl implements LoginService {

    @Resource
    private UserDao userDao;

    @Override
    public User getUserInfoByUsername(User user) {

        User userDB = userDao.getUserByName(user.getUsername());
        if(userDB == null ){
            return userDB;
        }else{
            String password = MD5Util.string2Md5(user.getPassword());
            if(userDB.getPassword().equals(password)){
                return userDB;
            }else {
                //账号密码错误
                return null;
            }
        }
    }
}
